<?php
namespace Wx\Controller;
use Think\Controller;
/*
*推荐店铺
*
*/
class RecommendController extends CommonController {
	
	public function index(){
		$member=D('member');
		$shop_community=D('shop_community');
		$area=D('area');
		
		$member_info = $member->where("id=".session('u_id'))->find();
        $this->assign('member_info',$member_info);
		
        // 省市区信息+小区信息
		if($member_info['c_id']>0){
			$c_info = M('shop_community')->where(array('id' => $member_info['c_id'] ))->find();
			$c_info['a_1_name'] = M('area')->where('id='.$c_info['a_id_1'])->getField('name');
			$c_info['a_2_name'] = M('area')->where('id='.$c_info['a_id_2'])->getField('name');
			$c_info['a_3_name'] = M('area')->where('id='.$c_info['a_id_3'])->getField('name');
		}
        $this->assign('c_info',$c_info);
		
		$this->display('recommend');
	}//end fun
	
	//
    public function save(){
		$shop_recommend=D('shop_recommend');
		$data['u_id']=session('u_id');
		$data['c_id']=$_POST['c_id'];
		$data['storename']=$_POST['storename'];
		$data['address']=$_POST['address'];
		$data['tel']=$_POST['tel'];
		$data['addtime']=time();
		$alt=$shop_recommend->add($data);
		if($alt){
			$this->success('感谢您推荐店铺！','/Wx/User/index');
			}else{
				$this->error('推荐失败');
			}
	}//end fun
	
	//
	
}//end class